import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/27 9:23
 * @description:
 */
public class CountWords {

  public static void main(String[] args) {
    System.out.println("亲输入一句英文，单词一空客封开");
    Scanner scanner=new Scanner(System.in);
    String sentence=scanner.nextLine();
    //以空格分割字符串
    String[] words=sentence.split(" ");
    //创建hashmap对象
    HashMap<String,Integer> hashMap=new HashMap<String,Integer>();
    //循环数组
    for (int i=0;i<words.length;i++){
      //取出key单词每一个元素
      String key=words[i];
      //集合中包含该单词
      if(hashMap.containsKey(words[i])){
        Integer value=hashMap.get(words[i]);
        value=value+1;
        hashMap.put(key,value);
      }else{
        //集合中不包含该单词直接添加value=1
        hashMap.put(key,1);
      }
    }
    //遍历
    Iterator iterator=hashMap.keySet().iterator();
    while (iterator.hasNext()){
           String key= (String) iterator.next();
           Integer value=hashMap.get(key);
      System.out.println(key+":"+value);
    }
  }

}
